package com.ternnetwork.oa.repository.note;


import com.ternnetwork.oa.entity.note.NoteCategory;
import com.ternnetwork.oa.entity.work.Event;
import com.ternnetwork.persistence.repository.BaseRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.Date;
import java.util.List;

public interface NoteCategoryRepository extends BaseRepository<NoteCategory, Long> {

    @Query("select count(1) from NoteCategory where createdById=?1 and name=?2 and parentId=?3")
    Long getCountByNameAndParentId(Long createdById,String name,Long parentId);

    @Query("select count(1) from NoteCategory where createdById=?1 and name=?2 and parentId=?3 and id!=?4")
    Long getCountByNameAndParentIdAndExcludeId(Long createdById,String name,Long parentId,Long excludeId);

    @Query("from NoteCategory t where t.createdById=?1 ")
    List<NoteCategory> findAll(Long createdById);

    @Query("select count(1) from NoteCategory where  parentId=?1")
    Long getCountByParentId(Long parentId);


}
